home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Workbench Add-On
/
Workbench Add-On - Volume 1.iso
/
Dev
/
Oberon
/
source
/
OC
/
OCPrefs.mod
< prev
next >
Wrap
Text File
|
1995-06-29
|
4KB
|
181 lines
(*************************************************************************
$RCSfile: OCPrefs.mod $
Description: Preferences editor for OC.
Created by: fjc (Frank Copeland)
$Revision: 2.1 $
$Author: fjc $
$Date: 1995/06/15 18:22:31 $
Copyright © 1995, Frank Copeland
This module forms part of the OC program
See OC.doc for conditions of use and distribution
Log entries are at the end of the file.
*************************************************************************)
<* STANDARD- *>
MODULE OCPrefs;
IMPORT
SYS := SYSTEM, Kernel, Errors, e := Exec, u := Utility, d := Dos,
OCM, s := OCPrefsStrings, wb := Workbench, OCPrefsGUI;
CONST
CopyrightStr = "Copyright © 1995 Frank Copeland\n";
(* -- Command line template and parsing ------------------------------- *)
CONST
template = "FROM";
optFROM = 0;
optCount = 1;
VAR
rdArgs : d.RDArgsPtr;
args : ARRAY optCount OF SYS.LONGWORD;
(* These are filled in by ParseArgs() *)
from : e.LSTRPTR;
(*
** Lock on starting directory when run from Workbench.
*)
VAR
startDir : d.FileLockPtr;
(*------------------------------------*)
PROCEDURE* Cleanup (VAR rc : LONGINT);
VAR oldDir : d.FileLockPtr;
BEGIN (* Cleanup *)
IF rdArgs # NIL THEN
d.FreeArgs (rdArgs);
d.FreeDosObject (d.rdArgs, rdArgs);
rdArgs := NIL
END;
s.CloseCatalog();
IF Kernel.fromWorkbench THEN oldDir := d.CurrentDir (startDir) END
END Cleanup;
(*------------------------------------*)
PROCEDURE Init ();
BEGIN (* Init *)
Kernel.SetCleanup (Cleanup);
s.OpenCatalog (NIL, "");
rdArgs := d.AllocDosObjectTags (d.rdArgs, u.end);
IF (rdArgs = NIL) THEN
OCPrefsGUI.Notice (s.msg15); HALT (d.warn)
END
END Init;
(*------------------------------------*)
PROCEDURE ParseArgs ();
VAR string : e.LSTRPTR; ignore : BOOLEAN;
BEGIN (* ParseArgs *)
from := SYS.VAL (e.LSTRPTR, args [optFROM]);
IF from = NIL THEN ignore := OCM.LoadPrefs ("OC.prefs")
ELSE ignore := OCM.LoadPrefs (from^)
END
END ParseArgs;
(*------------------------------------*)
PROCEDURE Main ();
(*------------------------------------*)
PROCEDURE WbArgs ();
VAR
wbStartup : wb.WBStartupPtr;
wbArg : wb.WBArg;
BEGIN (* WbArgs *)
wbStartup := SYS.VAL (wb.WBStartupPtr, Kernel.WBenchMsg);
IF wbStartup.numArgs > 2 THEN OCPrefsGUI.Notice (s.msg14); HALT (d.warn) END;
wbArg := wbStartup.argList [wbStartup.numArgs-1];
startDir := d.CurrentDir (wbArg.lock);
IF wbStartup.numArgs = 2 THEN
args [optFROM] := wbArg.name
END
END WbArgs;
(*------------------------------------*)
PROCEDURE CliArgs ();
VAR ignore : BOOLEAN;
BEGIN (* CliArgs *)
IF d.OldReadArgs (template, args, rdArgs) = NIL THEN
ignore := d.PrintFault (d.IoErr(), "");
HALT (d.warn)
END
END CliArgs;
BEGIN (* Main *)
IF Kernel.fromWorkbench THEN WbArgs()
ELSE CliArgs()
END;
ParseArgs();
OCPrefsGUI.Open;
END Main;
BEGIN (* OCPrefs *)
ASSERT (e.SysBase.libNode.version >= 37);
Errors.Init;
Init();
Main()
END OCPrefs.
(***************************************************************************
$Log: OCPrefs.mod $
# Revision 2.1 1995/06/15 18:22:31 fjc
# - Bumped version number
#
# Revision 1.6 1995/05/30 23:35:05 fjc
# - Removed most command-line arguments that over-rode
# preferences settings.
#
# Revision 1.6 1995/05/19 16:14:44 fjc
# - Completely rewritten as a GUI preferences editor. Removed
# all command line options other than the preferences file
# name.
#
# Revision 1.5 1995/04/02 14:08:10 fjc
# - Added CODESIZE and CONSTSIZE arguments.
#
# Revision 1.4 1995/03/10 14:42:28 fjc
# - Added new command line arguments: SMALLCODE, SMALLDATA,
# REGISTER, LARGECODE, LARGEDATA, NOREGISTER.
# - Moved more strings to catalog.
#
Revision 1.3 1995/01/26 00:17:17 fjc
- Release 1.5
Revision 1.2 1995/01/09 14:08:13 fjc
- Removed command line arguments for icon names.
- No longer checks for the existence of directories when
parsing the command line.
- Added MakeIcon() to create icons for preferences files.
- Implemented Workbench arguments.
Revision 1.1 1995/01/05 13:28:53 fjc
Initial revision
***************************************************************************)